package com.gas.project.gas.practice.service.impl;

import java.util.List;

import com.gas.common.utils.DateUtils;
import com.gas.common.utils.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gas.project.gas.practice.mapper.PracticeMapper;
import com.gas.project.gas.practice.domain.Practice;
import com.gas.project.gas.practice.service.IPracticeService;

/**
 * 社会实践Service业务层处理
 *
 * @author xyl
 * @date 2022-04-04
 */
@Service
public class PracticeServiceImpl implements IPracticeService {
    @Autowired
    private PracticeMapper practiceMapper;

    /**
     * 查询社会实践
     *
     * @param practiceId 社会实践ID
     * @return 社会实践
     */
    @Override
    public Practice selectPracticeById(Long practiceId) {
        return practiceMapper.selectPracticeById(practiceId);
    }

    /**
     * 查询社会实践列表
     *
     * @param practice 社会实践
     * @return 社会实践
     */
    @Override
    public List<Practice> selectPracticeList(Practice practice) {
        return practiceMapper.selectPracticeList(practice);
    }

    /**
     * 新增社会实践
     *
     * @param practice 社会实践
     * @return 结果
     */
    @Override
    public int insertPractice(Practice practice) {
        practice.setCreateTime(DateUtils.getNowDate());
        return practiceMapper.insertPractice(practice);
    }

    /**
     * 修改社会实践
     *
     * @param practice 社会实践
     * @return 结果
     */
    @Override
    public int updatePractice(Practice practice) {
        practice.setUpdateTime(DateUtils.getNowDate());
        return practiceMapper.updatePractice(practice);
    }

    /**
     * 删除社会实践对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deletePracticeByIds(String ids) {
        return practiceMapper.deletePracticeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除社会实践信息
     *
     * @param practiceId 社会实践ID
     * @return 结果
     */
    @Override
    public int deletePracticeById(Long practiceId) {
        return practiceMapper.deletePracticeById(practiceId);
    }

    @Override
    public String importPractice(List<Practice> practiceList) {
        for (Practice practice : practiceList) {
            practiceMapper.insertPractice(practice);
        }
        return "导入成功！";
    }
}
